package com.example.demo.Controller;

import com.example.demo.Entity.PersonalInfo;
import com.example.demo.Service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private ResumeService resumeService;
    @GetMapping("/user/{id}")
    @ResponseBody
    public PersonalInfo getuser(@PathVariable Long id){
        return resumeService.getUser(id);
    }
    @GetMapping("/users")
    @ResponseBody
    public List<PersonalInfo> getall(){return resumeService.getAll();}

    @PostMapping("/postuser")
    public void insert(@RequestBody PersonalInfo personalInfo){
        resumeService.insertUser(personalInfo);
    }
    @DeleteMapping("/deleteuser/{id}")
    public void delete(@PathVariable("id") Long id){resumeService.deleteUser(id);}
    @PutMapping("/update/{id}")
    public void update(@RequestBody PersonalInfo personalInfo,@PathVariable("id")Long id){resumeService.updateUser(personalInfo,id);}



}
